package com.cy.pj.brand.dao;

import com.cy.pj.brand.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

// 设定 该接口为mapper对象,  由 mybatis自动生成对象
@Mapper
public interface BrandDao {
//    通过注解 插入SQL语句
//    比较简单的语句用 注解方式开发,   复杂的使用*.xml 来完成
//    @Select("select * from tb_brand where name like CONCAT('%',#{name},'%')")
    List<Brand> findBrands(String name);


    @Delete("delete from tb_brand where id = #{id}")
    Integer deleteBrandById(Integer id);

    @Insert("insert into tb_brand value(#{id}, #{name},#{remark},now())")
    Integer insertBrand(Brand brand);

    Integer updateBrand(Brand brand);

    @Select(("select * from tb_brand where id = #{id}"))
    Brand findBrandById(Integer id);
}
